<?php

namespace App\Exports;
use App\Models\Depart;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class DepartExport implements FromView
{
   	public function __construct($where)
    {
        $this->where = $where;
    }

    public function view(): View
    {
        $query = Depart::query();
        if(array_get($this->where,'keyword')){
            $query->where('name','like','%'.$this->where['keyword'].'%');
        }
    	$list = $query->get();
    	
        return view('admin.depart.export_index', compact('list'));
    }
}
